package it.a.devil;

import java.lang.Thread.UncaughtExceptionHandler;

public class Main2 {

	public static void main(String[] args) {
		try {
			throw new Exception();
		} catch (Exception e) {
			System.out.println("here");
		}

		try {
			Thread t = new Thread(new Runnable() {

				@Override
				public void run() {
					throw new RuntimeException();
				}
			});
			Thread
					.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {

						@Override
						public void uncaughtException(Thread t, Throwable e) {
							System.out.println("thread name " + t.getName()
									+ " here2");
						}
					});
			t.start();
			t.join();
		} catch (Exception e) {
			e.printStackTrace();
		}

		Thread.setDefaultUncaughtExceptionHandler(null);

		try {
			new Thread(new Runnable() {

				@Override
				public void run() {
					throw new RuntimeException();
				}
			}).start();
		} catch (Exception e) {
			System.out.println("here3");
		}

	}
}
